package com.hunan.api.catv.entity.enums;

import org.springframework.util.ObjectUtils;

/**
 * 状态
 */
public enum State {


    invalid(0, "失效"),
    effective(1, "有效");

    private final Integer code;

    private final String msg;

    State(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static State getResult(int code) {
        if (ObjectUtils.isEmpty(code)) {
            return State.invalid;
        }
        State[] rcs = State.values();
        for (State rc : rcs) {
            if (rc.getCode().equals(code)) {
                return rc;
            }
        }
        return null;
    }
}
